/**
 * Created by TYC on 2016/3/27.
 */
import java.util.ArrayList;
public class ClientQueue{
    private ArrayList clients=new ArrayList();
    private ArrayList listeners=new ArrayList();
    public void addClientListener(ClientListener listener){
        listeners.add(listener);
    }
    public void add(Client client){
        clients.add(client);
        ClientEvent event=new ClientEvent(client);
        for(int i=0;i<listeners.size();i++){
            ClientListener listener=(ClientListener) listener.get(i);
            listener.client.Added(event);
        }
    }
    public void remove(Client client){
        client.remove(client);
        ClientEvent event=new ClientEvent(client);
        for(int i=0;i<listeners.size();i++){
            ClientListener listener=(ClientListener) listener.get(i);
            listener.client.Removed(event);
        }
    }
}